<template>
  <div class="my-events-container">
    <div class="welcome-section">
      <div class="welcome-content">
        <h2 class="welcome-title">欢迎来到我的社团活动</h2>
        <p class="welcome-message">这里是您参加和管理的所有社团活动的中心</p>
        <div class="welcome-stats">
          <div class="stat-box">
            <span class="stat-number">{{ joinedEventsCount }}</span>
            <span class="stat-label">已参加活动</span>
          </div>
          <div class="stat-box">
            <span class="stat-number">{{ upcomingEventsCount }}</span>
            <span class="stat-label">即将开始</span>
          </div>
          <div class="stat-box">
            <span class="stat-number">{{ completedEventsCount }}</span>
            <span class="stat-label">已完成活动</span>
          </div>
        </div>
        <div class="welcome-actions">
          <button class="action-btn primary-btn" @click="exploreEvents">探索更多活动</button>
          <button class="action-btn secondary-btn" @click="manageEvents">管理我的活动</button>
        </div>
      </div>
      <div class="welcome-illustration">
        <div class="activity-icon">🎉</div>
      </div>
    </div>
    
    <!-- 最近活动预览 -->
    <div class="recent-activities">
      <h3 class="section-title">最近活动</h3>
      <div class="activities-list">
        <div class="activity-item" v-for="(activity, index) in recentActivities" :key="index">
          <div class="activity-info">
            <h4 class="activity-name">{{ activity.name }}</h4>
            <p class="activity-date">{{ activity.date }}</p>
            <p class="activity-society">{{ activity.society }}</p>
          </div>
          <div class="activity-status" :class="activity.statusClass">{{ activity.status }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

// Emits
const emit = defineEmits(['navigate'])

// 活动统计数据
const joinedEventsCount = ref(12)
const upcomingEventsCount = ref(3)
const completedEventsCount = ref(9)

// 最近活动数据
const recentActivities = ref([
  {
    name: '编程爱好者交流会',
    date: '2024-09-05 14:00',
    society: '计算机社团',
    status: '即将开始',
    statusClass: 'status-upcoming'
  },
  {
    name: '技术分享会',
    date: '2024-08-20 10:30',
    society: '电子科技社团',
    status: '已完成',
    statusClass: 'status-completed'
  },
  {
    name: '校园音乐节',
    date: '2024-09-12 18:30',
    society: '音乐社团',
    status: '即将开始',
    statusClass: 'status-upcoming'
  }
])

// 按钮点击处理函数
const exploreEvents = () => {
  emit('navigate', 'all-events')
}

const manageEvents = () => {
  // 这里可以添加更多活动管理的逻辑
  console.log('管理我的活动')
}
</script>

<style scoped>
.my-events-container {
  width: 100%;
}

/* 欢迎区域 */
.welcome-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 40px;
  color: white;
  margin-bottom: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.welcome-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.welcome-title {
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.welcome-message {
  font-size: 18px;
  opacity: 0.9;
  margin: 0;
}

/* 统计数据 */
.welcome-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 16px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: transform 0.3s, background-color 0.3s;
}

.stat-box:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.2);
}

.stat-number {
  display: block;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 14px;
  opacity: 0.9;
}

/* 操作按钮 */
.welcome-actions {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.action-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.primary-btn {
  background-color: white;
  color: #667eea;
}

.secondary-btn {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
}

/* 欢迎插图 */
.welcome-illustration {
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-icon {
  font-size: 120px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* 最近活动部分 */
.recent-activities {
  background-color: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
}

.activities-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  transition: all 0.3s;
}

.activity-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.activity-info {
  flex: 1;
}

.activity-name {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0 0 4px 0;
}

.activity-date {
  font-size: 14px;
  color: #666;
  margin: 0 0 4px 0;
}

.activity-society {
  font-size: 12px;
  color: #999;
  margin: 0;
}

.activity-status {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

.status-upcoming {
  background-color: #e3f2fd;
  color: #1976d2;
}

.status-completed {
  background-color: #e8f5e9;
  color: #388e3c;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .welcome-section {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .welcome-stats {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  
  .welcome-actions {
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .welcome-section {
    padding: 24px;
  }
  
  .welcome-title {
    font-size: 24px;
  }
  
  .welcome-message {
    font-size: 16px;
  }
  
  .welcome-actions {
    flex-direction: column;
  }
  
  .action-btn {
    width: 100%;
  }
  
  .activity-icon {
    font-size: 80px;
  }
}
</style>